package com.ninjas.module.common.page;

import lombok.Data;
import org.springframework.http.HttpStatus;

import java.util.Collections;
import java.util.List;

@Data
public class PageResult {

    private Integer code;
    private String msg;
    private Object data;
    private long total;

    public static PageResult empty() {
        PageResult pageResult = new PageResult();
        pageResult.setCode(HttpStatus.OK.value());
        pageResult.setMsg("success");
        pageResult.setData(Collections.emptyList());
        pageResult.setTotal(0);
        return pageResult;
    }

    public static PageResult success(long total, List<?> list) {
        PageResult pageResult = new PageResult();
        pageResult.setCode(HttpStatus.OK.value());
        pageResult.setMsg("success");
        pageResult.setData(list);
        pageResult.setTotal(total);
        return pageResult;
    }
}
